home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / domacnost a kancelar / joomla / Joomla_1.5.4-Stable-Full_Package.exe / includes / menu.php < prev    next >
PHP Script  |  2008-07-06  |  2KB  |  84 lines

  1. <?php
  2. /**
  3.  * @version        $Id: menu.php 8682 2007-08-31 18:36:45Z jinx $
  4.  * @package        Joomla.Framework
  5.  * @subpackage    Application
  6.  * @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
  7.  * @license        GNU/GPL, see LICENSE.php
  8.  * Joomla! is free software. This version may have been modified pursuant
  9.  * to the GNU General Public License, and as distributed it includes or
  10.  * is derivative of works licensed under the GNU General Public License or
  11.  * other free or open source software licenses.
  12.  * See COPYRIGHT.php for copyright notices and details.
  13.  */
  14.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE') or die();
  17.  
  18. /**
  19.  * JMenu class
  20.  *
  21.  * @author Louis Landry   <louis.landry@joomla.org>
  22.  * @author Johan Janssens <johan.janssens@joomla.org>
  23.  * @package        Joomla.Framework
  24.  * @subpackage    Application
  25.  * @since        1.5
  26.  */
  27. class JMenuSite extends JMenu
  28. {
  29.     /**
  30.      * Loads the entire menu table into memory
  31.      *
  32.      * @access public
  33.      * @return array
  34.      */
  35.     function load()
  36.     {
  37.         // Initialize some variables
  38.         $db        = & JFactory::getDBO();
  39.  
  40.         $sql    = 'SELECT m.*, c.`option` as component' .
  41.                 ' FROM #__menu AS m' .
  42.                 ' LEFT JOIN #__components AS c ON m.componentid = c.id'.
  43.                 ' WHERE m.published = 1'.
  44.                 ' ORDER BY m.sublevel, m.parent, m.ordering';
  45.         $db->setQuery($sql);
  46.  
  47.         if (!($menus = $db->loadObjectList('id'))) {
  48.             JError::raiseWarning('SOME_ERROR_CODE', "Error loading Menus: ".$db->getErrorMsg());
  49.             return false;
  50.         }
  51.  
  52.         foreach($menus as $key => $menu)
  53.         {
  54.             //Get parent information
  55.             $parent_route = '';
  56.             $parent_tree  = array();
  57.             if(($parent = $menus[$key]->parent) && (isset($menus[$parent])) &&
  58.                 (is_object($menus[$parent])) && (isset($menus[$parent]->route)) && isset($menus[$parent]->tree)) {
  59.                 $parent_route = $menus[$parent]->route.'/';
  60.                 $parent_tree  = $menus[$parent]->tree;
  61.             }
  62.  
  63.             //Create tree
  64.             array_push($parent_tree, $menus[$key]->id);
  65.             $menus[$key]->tree   = $parent_tree;
  66.  
  67.             //Create route
  68.             $route = $parent_route.$menus[$key]->alias;
  69.             $menus[$key]->route  = $route;
  70.  
  71.             //Create the query array
  72.             $url = str_replace('index.php?', '', $menus[$key]->link);
  73.             if(strpos($url, '&') !== false)
  74.             {
  75.                $url = str_replace('&','&',$url);
  76.             }
  77.  
  78.             parse_str($url, $menus[$key]->query);
  79.         }
  80.  
  81.         $this->_items = $menus;
  82.     }
  83. }
  84.